#include<ctype.h>
#include<conio.h>
#include<fstream.h>
#include<string.h>
#include<stdlib.h>

// Program to enter the source program.

class oprec
{
   protected:
   char label[10];
   char mnemonic[6];
   char operand[10];
   public:
   oprec()
   {
   strcpy(mnemonic,"");
   strcpy(label,"");
   strcpy(operand,"");
   }
   void indata(int i)
   {
	gotoxy(2,i+4);
	cin>>label;
	gotoxy(15,i+4);
	cin>>mnemonic;
	gotoxy(27,i+4);
	cin>>operand;
   }
   void outdata(int i)
   {
	gotoxy(2,i+4);
	cout<<label;
	gotoxy(15,i+4);
	cout<<mnemonic;
	gotoxy(27,i+4);
	cout<<operand;
   }
   char* retmnemonic()
   { return mnemonic;
   }
   char* retlabel()
   { return label;
   }
   char* retoperand()
   { return operand;}

}; // end of class
class outrec:public oprec
{
  char objcode[10];
  public:
  void setmnemonic(char x[])
  {
  strcpy(mnemonic,x);
  }
  void setlabel(char x[])
  {
  strcpy(label,x);
  }
  void setoperand(char x[])
  {
  strcpy(operand,x);
  }
  void setobjcode(char x[])
  {
  strcpy(objcode,x);
  }
  void display(int i)
  { gotoxy(2,i+4);
	cout<<label;
	gotoxy(15,i+4);
	cout<<mnemonic;
	gotoxy(27,i+4);
	cout<<operand;
	gotoxy(40,i+4);
	cout<<objcode;
   }
};// end of class



void edit()
{
 oprec rec;
 int i=0,j,n;
 int ptr,prev;
 ofstream of;
 ifstream is;
/*
clrscr();
 cout<<"---------------------------------";
 cout<<"\n LABEL        MNEMONIC    OPERAND";
 cout<<"\n---------------------------------";
 of.open("source.dat",ios::out|ios::binary);
 rec.indata(i);
 while((strcmpi(rec.retlabel(),"/")!=0)||(strcmpi(rec.retmnemonic(),"/")!=0))
 {
  of.write((char*)&rec,sizeof(rec));
  i++;
  if(i==20)
  {i=0;
   getch();
   clrscr();
   cout<<"---------------------------------";
   cout<<"\n LABEL        MNEMONIC    OPERAND";
   cout<<"\n---------------------------------";
  }
  rec.indata(i);

 }//END OF WHILE
 cout<<"\n---------------------------------";
 of.close();

 getch();


 */

 clrscr();

 cout<<"---------------------------------";
 cout<<"\n LABEL        MNEMONIC    OPERAND";
 cout<<"\n---------------------------------";
 i=0;
 is.open("source.dat",ios::in|ios::binary);
 while(!is.eof())
 {
  is.read((char*)&rec,sizeof(rec));
  if(!is.eof())
  {
	i;
	if(i==20)
	 {i=0;
	  getch();
	  clrscr();
	cout<<"---------------------------------";
	cout<<"\n LABEL        MNEMONIC    OPERAND";
	cout<<"\n---------------------------------";
	  }
	rec.outdata(i);
	i++;
   }
 }//END OF WHILE
 cout<<"\n---------------------------------";
 is.close();


 getch();
}
/*void main()
{
edit();
}
*/